package com.xuetang9.t9.xinhuaxia.mappers;

import com.xuetang9.t9.xinhuaxia.beans.SocialPublish;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SocialPublishMapper extends Mapper<SocialPublish> {


    @Select("SELECT ifnull(MAX(p_id),0) FROM social_publish")
    @ResultType(Integer.class)
    int getSocialPublishMaxCountId();

    @Select("SELECT * FROM social_publish where p_userId=#{userid}")
    @Results({@Result(column="p_id",property="pId"),
           @Result(column="p_userId",property="pUserid"),
           @Result(column="p_workTitle",property="pWorktitle"),
           @Result(column="p_modelname",property="pModelname"),
           @Result(column="p_photographer" ,property="pPhotographer"),
           @Result(column="p_tag" ,property="pTag"),
           @Result(column="p_photodescribe" , property="pPhotodescribe"),
           @Result(column="p_like",property="pLike")
            } )
    List<SocialPublish> queryAllByUserid(@Param("userid") Integer userid);

    @Update("Update social_publish Set p_like =p_like+1 Where p_id=#{pId}")
    @ResultType(Integer.class)
    int modifyLike(@Param("pId") Integer pId);
}